<?php

namespace App\Jobs;

use App\Lib\Notices\JPushNotices;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class MessageQueue implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    private $userId;
    private $params;
    // ios端的播放语音的标识
    private $sound;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($userId,$params,$delay=null)
    {
    	$this->userId = $userId;
        $this->params = $params;
        if(isset($delay)){
	        $this->delay($delay);
        }
        $this->onQueue('Messages');
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
	    (new JPushNotices())->sendNotice($this->userId,$this->params);
    }
}
